package  ${pkName}.service.impl;

import ${pkName}.entity.${className?cap_first};
import ${pkName}.mapper.${className?cap_first}Mapper;
import ${pkName}.service.${className?cap_first}Service;
import java.util.List;
import java.util.Date;
import java.io.Serializable;
import cn.wyj.common.util.KeyGenerator;
import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import com.github.pagehelper.PageInfo;
@Service
@Transactional
public class ${className?cap_first}ServiceImpl   implements ${className?cap_first}Service{
 @Autowired
    public ${className?cap_first}Mapper  mapper;
    protected Logger logger = LoggerFactory.getLogger(${className?cap_first}ServiceImpl.class);

    /**
     * 根据id删除对象
     *
     * @param id id
     */
    @Override
    public void del(Serializable id) {
        mapper.deleteById(id);
    }

    /**
     * 根据id数组,删除对象
     *
     * @param ids id数组
     */
    @Override
    public void delByIds(Serializable[] ids) {
        mapper.deleteByIds(ids);
    }

    /**
     * 更新
     *
     * @param e
     */
    @Override
    public void update(${className?cap_first} e) {
        mapper.updateById(e);

    }


    /**
     * 保存
     *
     * @param e
     */
    @Override
    public int save(${className?cap_first} e) {
        e.setId(KeyGenerator.getUUId());
        return mapper.insert(e);
    }


    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public List<${className?cap_first}> findAll() {
    return mapper.selectAll();
    }

    /**
    * 按ID查询
    *
    * @param id id
    * @return
    */
    @Override
    public ${className?cap_first} findById(Serializable id) {
    return mapper.selectById(id);
    }

    @Override
    public PageInfo<${className?cap_first}> findByPage(int index, int pageSize) {
        PageHelper.startPage(index, pageSize);
        List<${className?cap_first}> list = mapper.selectAll();
            return new PageInfo<>(list);
            }

    @Override
    public PageInfo<${className?cap_first}> findByPageCondition(int index, int pageSize, Object condition) {
        PageHelper.startPage(index, pageSize);
        List<${className?cap_first}> list = mapper.selectByCondition(condition);
            return new PageInfo<>(list);
    }

}
